package edu.hcmus.sow.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import edu.hcmus.sow.domain.Authorities;

/**
 * DAO to manage Authorities entities.
 * 
 */
@Repository("AuthoritiesDAO")
@Transactional
public class AuthoritiesDAOImpl extends AbstractHibernateDAO<Authorities, Integer> implements AuthoritiesDAO {
   public Authorities getAuthority(String authority) throws DataAccessException {
      List<Authorities> authorities = findByCriteria(Restrictions.eq("authority", authority));
      return authorities.size() == 0 ? null : authorities.get(0);
   }
}
